/*****************************************************************************

                 ,//////,   ,////    ,///' /////,
                ///' ./// ///'///  ///,    ,, //
               ///////,  ///,///   '/// ///''\\,
             ,///' '///,'/////',/////'  /////'\\,

    Copyright 2010 Marcus Jansson <mjansson256@yahoo.se>

    This file is part of ROSA - Realtime Operating System for AVR32.

    ROSA is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ROSA is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ROSA.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
/* Tab size: 4 */

//Standard library includes
#include <avr32/io.h>
#include <stdlib.h>
#include <malloc.h>

//Kernel includes
#include "API/rosa.h"

//Driver includes
#include "drivers/led.h"
#include "drivers/delay.h"
#include "drivers/usart.h"
#include "kernel/rosa_queues.h"
#include "testFramework.h"
#include "ee_printf.h"

//Include configuration
#include "rosa_config.h"

//Data blocks for the tasks
#define T1_STACK_SIZE 0x100
#define T2_STACK_SIZE 0x100

void testScheduler(void);
void testSemaphores(void);
/*************************************************************
 * Main function
 ************************************************************/
int main(void)
{
	//Initialize the ROSA kernel
	ROSA_init();
	struct mallinfo m = mallinfo();
	ee_printf("Before: malloc memory used: %d free: %d bytes total: %d bytes\n", m.uordblks, m.fordblks, m.arena);

	testScheduler();
	testSemaphores();
	
	ee_printf("------------------------------------\n");
	ee_printf("Total number of successful tests: %d\n", successfulTests);
	ee_printf("Total number of failed tests: %d\n", failedTests);
	ee_printf("Total number of tests: %d\n", totalNumberOfTestCases);
	
	ee_printf("After: malloc memory used: %d free: %d bytes total: %d bytes\n", m.uordblks, m.fordblks, m.arena);
	/* Execution will never return here */
	asm("breakpoint");
	while(1);
}
